<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:sec="http://www.springframework.org/security/tags"
      xmlns:c="http://java.sun.com/jsp/jstl/core">

    <h:head>
        <title> Biblioteca DAI JSF + SPRING </title>

        <script src="./jQuery/js/jquery.paginate.js" type="text/javascript"></script>
        <script src="./jQuery/js/jquery-latest.pack.js" type="text/javascript"></script>

        <style>
            body {
                width: 1100px;
                margin: 35px auto;
                font-family:Arial, Helvetica, sans-serif;
                color:#51555C;
                height:100%;
                font-size:14px;
                background-color: #708090;
            }



            #listBook{
                position: absolute;
                left: 44%;
                top:26%;
                height: 85%;
                margin-top: 5px;
                width: 45%;
                margin-left: -150px;
                z-index: 1;
            }
            #idiomaSel{
                position: absolute;
                right:3%;
                top:1%;
                z-index: 1;
            }
            #derecha{
                position: relative;
                left:1%;
                top:1%;
                z-index: 1;
            }
            #mp{
                z-index: 2;
            }
            #pnel{
                z-index: 1;

            }
            #calendar{
                z-index: 1;
                top:20%;
            }
            #tabla{
                right: 3%;
                position: absolute;
            }

        </style>

    </h:head>

    <h:body>

        <p:growl id="growl1" showDetail="true" autoUpdate="true"/>

        <!-- <p:graphicImage url="/resources/images/banner1.gif" alt="no imagen" /> -->

        <div id="derecha" >

            <sec:authorize access="hasRole('ROLE_ADMIN')">
                <h:outputLabel value="#{msg.permisosA}" style="font-size: 18px"  />
            </sec:authorize>
            <sec:authorize access="hasRole('ROLE_USER')">
                <h:outputLabel value="#{msg.permisosU}" style="font-size: 18px"/>
            </sec:authorize>

            <c:if test="#{empty sessionScope.SPRING_SECURITY_CONTEXT.authentication.principal}" >
                <h:outputLabel value="#{msg.anonimo}" style="font-size: 18px"/>
            </c:if>

        </div>

        <div id="idiomaSel" >
            <h:outputLabel value="#{msg.idioma_sel}"/><br></br>
            <center>
                <h:outputLink  value="cambiarIdioma-flow"  >
                    <f:param name="idioma" value="es" />
                    <h:graphicImage library="images" name="spain.png" title="#{msg.traducir_es}" />
                </h:outputLink>

                <h:outputLink  value="cambiarIdioma-flow"  >
                    <f:param name="idioma" value="en" />
                    <h:graphicImage library="images" name="england.png" title="#{msg.traducir_en}" />
                </h:outputLink>
            </center>
        </div>

        <br></br>
        <br></br>
        <div id="cont" >
        <p:menubar id="mp" >

            <sec:authorize access="hasRole('ROLE_ADMIN')">
                <p:submenu label="#{msg.libros}" id="lbr"  >
                    <p:menuitem ajax="false" url="altasL-flow" value="#{msg.altas}"  ></p:menuitem>
                    <p:menuitem ajax="false" url="bajasmodL-flow" value="#{msg.modificaciones}" ></p:menuitem>
                </p:submenu>
            </sec:authorize>

            <c:if test="#{not empty sessionScope.SPRING_SECURITY_CONTEXT.authentication.principal}" >
                <p:menuitem value="#{msg.v_libros}" url="verLibros-flow" ajax="false" rendered="#{not empty sessionScope.SPRING_SECURITY_CONTEXT.authentication.principal}" update="mp" />
            </c:if>


            <c:if test="#{not empty sessionScope.SPRING_SECURITY_CONTEXT.authentication.principal}" >
                <p:menuitem value="Favoritos" url="favoritos-flow" ajax="false" rendered="#{not empty sessionScope.SPRING_SECURITY_CONTEXT.authentication.principal}" update="mp" />
            </c:if>

            <sec:authorize access="hasRole('ROLE_ADMIN')">
                <p:menuitem value="Pedidos" url="adminPedido-flow" ajax="false" rendered="#{not empty sessionScope.SPRING_SECURITY_CONTEXT.authentication.principal}" update="mp" />
            </sec:authorize>



            <ui:remove>
                <sec:authorize access="hasRole('ROLE_ADMIN')">
                    <p:submenu label="Prestamos/Devoluciones" id="pre"  >
                        <p:menuitem ajax="false" url="prstamo-flow" value="Prestamo" ></p:menuitem>
                        <p:menuitem ajax="false" url="altasL-flow" value="Devolucion" ></p:menuitem>
                    </p:submenu>
                </sec:authorize>
            </ui:remove>

            <sec:authorize access="hasRole('ROLE_ADMIN')">
                <p:submenu label="#{msg.usuario}" id="soc"  >
                    <p:menuitem ajax="false" url="bajasmodU-flow" value="#{msg.modificaciones}" ></p:menuitem>
                </p:submenu>
            </sec:authorize>

           <p:submenu label="#{msg.noticia}" id="nt"  >
                <sec:authorize access="hasRole('ROLE_ADMIN')">
                    <p:menuitem ajax="false" url="noticia-flow" value="#{msg.cnoticia}" ></p:menuitem>
                </sec:authorize>
            </p:submenu>

            <p:menuitem ajax="false" url="verNoticia-flow" value="#{msg.vnoticia}" ></p:menuitem>

            <p:menuitem value="#{msg.perfil}" url="perfil-flow" ajax="false" rendered="#{not empty sessionScope.SPRING_SECURITY_CONTEXT.authentication.principal}" update="mp" />

            <p:menuitem value="#{msg.sesion}" url="registroU-flow" icon="ui-icon-disk"  ajax="false" rendered="#{empty sessionScope.SPRING_SECURITY_CONTEXT.authentication.principal}" update="mp"/>


            <p:menuitem id="tabla" value="#{msg.desconectar}" url="desconectar-flow"  ajax="false" rendered="#{not empty sessionScope.SPRING_SECURITY_CONTEXT.authentication.principal}" update="mp" icon="./stylesheets/logout.png" />

        </p:menubar>

        <br></br>
        <br></br>

        <!-- Info Pagina-->

        <p:panel id="pnel" header="#{msg.directo}" style="float: right" >
            <h:outputLink value="perfil-flow" rendered="#{not empty sessionScope.SPRING_SECURITY_CONTEXT.authentication.principal}"> #{msg.perfil}</h:outputLink><br></br>
            <h:outputLink value="registroU-flow" rendered="#{empty sessionScope.SPRING_SECURITY_CONTEXT.authentication.principal}">#{msg.sesion}</h:outputLink><br></br>
            <sec:authorize access="hasRole('ROLE_USER')">
                <h:outputLink value="verLibros-flow" >#{msg.v_libros}</h:outputLink><br></br>
            </sec:authorize>
            <sec:authorize access="hasRole('ROLE_ADMIN')">
                <h:outputLink value="bajasmodL-flow" >#{msg.b_libros}</h:outputLink><br></br>
            </sec:authorize>
            <h:outputLink value="desconectar-flow"  rendered="#{not empty sessionScope.SPRING_SECURITY_CONTEXT.authentication.principal}">#{msg.desconectar}</h:outputLink><br></br>
        </p:panel>



        <!--calendario -->
        <table id="relCad" >
            <tr>
                <td>
            <p:calendar id="calendar" value="#{calendarioControlador.date}"  mode="inline"  />
            </td>
            </tr>
            <tr>
                <td>

                </td>
            </tr>
        </table>




        <!--calendario -->
        <br></br>
        <br></br>
        <div id="listBook" >
            <h:form>
                <p:panel id="listBook" header="#{msg.u_not}" rendered="#{noticiaControlador.noticias != null}"  >
                    <ui:repeat value="#{noticiaControlador.noticias}" var="noti"  >
                        <center>
                            <fieldset>
                                <h:panelGrid>
                                    <f:facet name="header">
                                        <h:outputText value="#{msg.fecha}: #{noti.fecha}"/>
                                    </f:facet>
                                    <h:outputText value="#{msg.titulo}: #{noti.titulo}"/><br></br>
                                    <h:outputText value="#{noti.contenido}"/>
                                </h:panelGrid>
                            </fieldset>
                        </center>
                    </ui:repeat>
                </p:panel>
            </h:form>
            <h:outputText id="listBook" value="#{msg.vacio}" rendered="#{noticiaControlador.noticias == null}"/>
        </div>
    </div>
    </h:body>

</html>